package com.karaoke.android.data.domain

import android.databinding.ObservableBoolean
import android.databinding.ObservableField
import android.databinding.ObservableFloat
import io.realm.RealmObject
import io.realm.annotations.Ignore
import io.realm.annotations.PrimaryKey

open class Song : RealmObject()
{
    @PrimaryKey
    var id: String = ""

    var name: String = ""

    var inputCode: String? = null

    var wordCount: Int? = null

    var langId: Int? = null

    var typeId: Int? = null

    var albumId: Int? = null

    var singers: String = ""


    private var lVolume: Int = 0

    private var rVolume: Int = 0

    var amTrack: Short = 1

    var quality: String? = null

    var fullCode: String? = null


    var filename: String? = null

    var filepath: String? = null

    var hot: Int = 0

    var isNew: Boolean = false

    var isRecommend: Boolean = false

    var isPublic: Boolean = false

    var resolution: String? = null

    var isHd: Boolean = false

    var image: String? = null

    var imageUrl: String? = null

    var playUrl: String? = null

    var isSelect: Boolean? = null

    var isPlay: Boolean? = null

    var isTemp: Boolean = false


    override fun equals(other: Any?): Boolean
    {
        if (other is Song)
        {
            return this.id == other.id
        }
        return false
    }

    override fun hashCode(): Int
    {
        var result = id.hashCode()
        result = 31 * result + name.hashCode()
        result = 31 * result + (inputCode?.hashCode() ?: 0)
        result = 31 * result + (wordCount ?: 0)
        result = 31 * result + (langId ?: 0)
        result = 31 * result + (typeId ?: 0)
        result = 31 * result + (albumId ?: 0)
        result = 31 * result + singers.hashCode()
        result = 31 * result + lVolume
        result = 31 * result + rVolume
        result = 31 * result + amTrack
        result = 31 * result + (quality?.hashCode() ?: 0)
        result = 31 * result + (fullCode?.hashCode() ?: 0)
        result = 31 * result + (filename?.hashCode() ?: 0)
        result = 31 * result + (filepath?.hashCode() ?: 0)
        result = 31 * result + hot
        result = 31 * result + isNew.hashCode()
        result = 31 * result + isRecommend.hashCode()
        result = 31 * result + isPublic.hashCode()
        result = 31 * result + (resolution?.hashCode() ?: 0)
        result = 31 * result + isHd.hashCode()
        result = 31 * result + (image?.hashCode() ?: 0)
        result = 31 * result + (imageUrl?.hashCode() ?: 0)
        result = 31 * result + (playUrl?.hashCode() ?: 0)
        result = 31 * result + (isSelect?.hashCode() ?: 0)
        result = 31 * result + (isPlay?.hashCode() ?: 0)
        return result
    }

    fun onClick()
    {
        isSelect = true
    }

    @Ignore
    val btnDingVisibility = ObservableBoolean().apply { set(true) }
    @Ignore
    val btnDeleteVisibility = ObservableBoolean()
    @Ignore
    val flagVisibility = ObservableBoolean().apply { set(false) }
    @Ignore
    val swipeIconAlpha = ObservableFloat().apply { set(1F) }
    @Ignore
    val flagText = ObservableField<String>().apply { set("") }
}